/**
 * 构造函数 Person
 */
function Person() {
    this.name = '中国人'
    this.pets = ['小煤球', 'java']
}
Person.prototype.run = function (params) {
    console.log("跑");
}

/**
 * 构造函数 Student
 */
function Student() {
    //1.构造函数继承
    Person.call(this)
    this.num = '学号'
}

//2.寄生式继承
// 1.创建一个空的构造函数
function Temp() { }
//2.修改空构造函数原型为Person原型
Temp.prototype = Person.prototype
const stuPrototype = new Temp()
//3.修改学生构造函数原型为stuPrototype原型
Student.prototype = stuPrototype
// 4.修改constructor指向
Student.prototype.constructor = Student


//使用Object.create
Student.prototype = Object.create(Person.prototype)
Student.prototype.constructor = Student



//寄生式组合继承比较完美；


const p1 = new Student()


p1.pets.push('小猫')
console.log(p1);
console.log(p1.name);
p1.run()


const p2 = new Student()
console.log(p2);